<!DOCTYPE html>
<html>

<head>
    <include file="Share:meta" />
    <script src="../Public/plugins/citySelect/jsAddress.js"></script>
    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=658d2c726177edbae353e8de47c171f4&plugin=AMap.Autocomplete"></script>
    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css" />
    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=658d2c726177edbae353e8de47c171f4"></script>
    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=658d2c726177edbae353e8de47c171f4&plugin=AMap.Geocoder"></script>
    <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
</head>

<body class="hold-transition skin-blue sidebar-mini">
    <div class="wrapper">
        <include file="Share:header" />
        <include file="Share:left" />
        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>顾客管理<small></small></h1>
                <ol class="breadcrumb">
                    <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
                    <li class="active">新增、修改</li>
                </ol>
            </section>
            <!-- Main content -->
            <section class="content">
                <div class="box box-info">
                    <div class="box-header with-border">
                        <h3 class="box-title"><empty name="Think.get.cid">新增顾客<else />修改顾客</empty></h3>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form class="form-horizontal" action="__APP__/Admin/Customer/clist" method="post" enctype="multipart/form-data">
                        <input type="hidden" name="cid" value="{$info.cid}" />
                        <input type="hidden" name="uid" value="{$info.uid}" />
                        <div class="box-body">
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">新系统ID</label>
                                <div class="col-sm-10">
                                    <input type="text" disabled="" name="" id="inputEventCode" class="form-control" value="{$info.hash}" autocomplete="off" placeholder="新系统ID,自动生成">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">原系统ID</label>
                                <div class="col-sm-10">
                                    <eq name="info.sourceid" value="">
                                        <input type="text" name="sourceid" id="inputEventCode" class="form-control" value="{$info.sourceid}" autocomplete="off" placeholder="原系统ID,新增可不填!">
                                        <else />
                                        <input type="text" name="sourceid" id="inputEventCode" class="form-control" value="{$info.sourceid}" autocomplete="off" placeholder="原系统ID,新增可不填!">
                                    </eq>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">头像</label>
                                <div class="col-sm-10">
                                    <div class="btn-group">
                                        <if condition="$info.cid eq ''">
                                            <label title="上传头像" for="inputImage" class="btn btn-primary">
                                                <i class="fa fa-upload"></i>
                                                <input type="file" name="Avatar" id="inputImage" class="hide"> 上传头像
                                            </label>
                                            <else/>
                                            <img class="img-responsive" src="{$info.Avatar}" width="100px;" height="100px;" />
                                            <a href="javascript:void(0)" class="editpic">&nbsp;更换</a>
                                        </if><span id="file"></span>
                                    </div>
                                    <div style="color:#f00;">&nbsp;如需图片上传请到新版</div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">手机</label>
                                <div class="col-sm-10">
                                    <input type="text" name="mobile" id="inputEventCode" class="form-control" value="{$info.mobile}" autocomplete="off" required="required">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">代理商ID</label>
                                <div class="col-sm-10">
                                    <input type="number" name="uid" id="inputEventCode" class="form-control" value="{$info.uid}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">上级消费者ID</label>
                                <div class="col-sm-10">
                                    <input type="number" name="parentcid" id="inputEventCode" class="form-control" value="{$info.parentcid}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">公司名称</label>
                                <div class="col-sm-10">
                                    <input type="text" name="company" id="inputEventCode" class="form-control" value="{$info.company}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">中文名</label>
                                <div class="col-sm-10">
                                    <input type="text" name="name" id="inputEventCode" class="form-control" value="{$info.name}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">英文名</label>
                                <div class="col-sm-10">
                                    <input type="text" name="name_en" id="inputEventCode" class="form-control" value="{$info.name_en}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">职位</label>
                                <div class="col-sm-10">
                                    <input type="text" name="title" id="inputEventCode" class="form-control" value="{$info.title}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">电话</label>
                                <div class="col-sm-10">
                                    <input type="text" name="telephone" id="inputEventCode" class="form-control" value="{$info.telephone}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">传真</label>
                                <div class="col-sm-10">
                                    <input type="text" name="fax" id="inputEventCode" class="form-control" value="{$info.fax}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">邮箱</label>
                                <div class="col-sm-10">
                                    <input type="email" name="email" id="inputEventCode" class="form-control" value="{$info.email}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">微博</label>
                                <div class="col-sm-10">
                                    <input type="text" name="weibo" id="inputEventCode" class="form-control" value="{$info.weibo}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">QQ</label>
                                <div class="col-sm-10">
                                    <input type="text" name="qq" id="inputEventCode" class="form-control" value="{$info.qq}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">微信</label>
                                <div class="col-sm-10">
                                    <input type="text" name="weixin" id="inputEventCode" class="form-control" value="{$info.weixin}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">网站</label>
                                <div class="col-sm-10">
                                    <input type="text" name="site" id="inputEventCode" class="form-control" value="{$info.site}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">地址</label>
                                <div class="col-sm-10">
                                    <input type="text" name="address" id="address" class="form-control" value="{$info.address}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">经度</label>
                                <div class="col-sm-10">
                                    <input type="text" name="longitude" id="longitude" class="form-control" value="{$info.longitude}" placeholder="鼠标点击获取经纬度"  autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">纬度</label>
                                <div class="col-sm-10">
                                    <input type="text" placeholder="鼠标点击获取经纬度" id="latitude" name="latitude" class="form-control" value="{$info.latitude}" autocomplete="off">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">搜索</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" id="amapKeywords" name="keywords" value="" placeholder="关键字" />
                                </div>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" id="amapCity" name="city" value="" placeholder="城市" />
                                </div>
                                <div class="col-sm-2">
                                   <button type="button" onClick="searchamap()" class="btn btn-info">搜索</button>
                                </div>

                                <div class="col-sm-2">
                                   <a target="_blank" class="btn btn-default" href="http://lbs.amap.com/console/show/picker" role="button">坐标拾取器</a>
                                </div>
                                
                            </div>
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">地图</label>
                                <div class="col-sm-10">
                                    <div style="width: 600px;height: 500px;">
                                        <div id="container" style="width: 600px;height: 500px;margin-left: 15px;">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer col-sm-offset-2">
                            <button type="submit" class="btn btn-primary">
                                <eq name="info" value="">保存
                                    <else />保存</eq>
                            </button>
                            <a class="btn btn-warning" href="__APP__/Admin/Customer/clist" role="button">返回</a>
                        </div>
                        <br>
                        <!-- /.box-footer -->
                    </form>
                </div>
            </section>
            <!-- /.content -->
        </div>
        <!-- /.content-wrapper -->
        <include file="Share:copyright" />
        <include file="Share:setting" />
    </div>
    <include file="Share:js" />
    <script type="text/javascript">
    $("#CustomerManager").addClass("active");
    $("#customer_list").addClass("active");

    $(function() {
        // Replace the <textarea id="editor1"> with a CKEditor
        // instance, using default configuration.
        //      CKEDITOR.replace('introduction');
        //bootstrap WYSIHTML5 - text editor
        $(".textarea").wysihtml5();

        $('.editpic').click(function() {
            $('#file').after('<br/><div class="btn-group">' +
                '<label title="上传头像" for="inputImage" class="btn btn-primary">' +
                '<i class="fa fa-upload"></i>' +
                '<input type="file" name="Avatar" id="inputImage" class="hide"> 上传头像' +
                '</label> ' +
                '</div>');

        });
    });
    </script>
    <script type="text/javascript">
    //经纬度解析成地理地址start
    function regeocoder(lng, lat, is_change) { //逆地理编码
        lnglatXY = [lng, lat];
        var geocoder = new AMap.Geocoder();
        geocoder.getAddress(lnglatXY, function(status, result) {
            if (status === 'complete' && result.info === 'OK') {
                var address = result.regeocode.formattedAddress; //返回地址描述
                if (is_change == 1) {
                    document.getElementById("address").value = address;
                }
            } else {
                alert('地址定位解析失败,请确认允许浏览器获取你的地理位置信息');
            }
        });
    }
    //经纬度解析成地理地址end
    //浏览器定位
    var map, geolocation, lng, lat;
    //加载地图，调用浏览器定位服务
    map = new AMap.Map('container', {});
    // map.plugin('AMap.Geolocation', function() {
    //     geolocation = new AMap.Geolocation({});
    //     geolocation.getCurrentPosition();
    //     AMap.event.addListener(geolocation, 'complete', onComplete); //返回定位信息
    // });
    // //解析定位结果
    // function onComplete(data) {
    //     lng = data.position.getLng(); //经度
    //     lat = data.position.getLat(); //纬度
    //     if (!$('#longitude').attr('value')) {
    //         document.getElementById("longitude").value = lng;
    //     }
    //     if (!$('#latitude').attr('value')) {
    //         document.getElementById("latitude").value = lat;
    //     }
    //     if ('') {
    //         lng = '';
    //         lat = '';
    //     }
    //     regeocoder(lng, lat, 0); //将经纬度解析为地理位置信息
    //     chooseLngLat(lng, lat);
    // }


    //    function bigPin(lng,lat){
    //        //大头针start
    //        var map = new AMap.Map("container", {
    //            center: [lng,lat],
    //            zoom: 14
    //        });
    //
    //        var marker = new AMap.Marker({
    //            position: map.getCenter(),
    //            draggable: true,
    //            cursor: 'move',
    //            raiseOnDrag: true
    //        });
    //        marker.setMap(map);
    //        //大头针end
    //    }
    </script>
    <script>
    // chooseLngLat({$info.longitude|default="118.087632"},{$info.latitude|default="24.442923"});

    function chooseLngLat(Lng, Lat) {
        var chooseLng = '';
        var chooseLat = '';

        map = new AMap.Map('container', {
            center: [Lng, Lat],
            zoom: 22
        });
        map.setDefaultCursor("url('http://aliyun06.hjie.net:8060/Tpl/Console/Public/Bizcard/icon/datouzhens.png'),pointer"); //替换大头针的样式

        //为地图注册click事件获取鼠标点击出的经纬度坐标
        var clickEventListener = map.on('click', function(e) {
            //   document.getElementById("lnglat").value = e.lnglat.getLng() + ',' + e.lnglat.getLat();
            document.getElementById("latitude").value = e.lnglat.getLat();
            document.getElementById("longitude").value = e.lnglat.getLng();

            chooseLng = e.lnglat.getLng(); //用户点击时间获取的经纬度
            chooseLat = e.lnglat.getLat();

            chooseLngLat(chooseLng, chooseLat);
            regeocoder(chooseLng, chooseLat, 1);
        });

        //用大头针在地图上将位置标注
        var marker = new AMap.Marker({
            position: map.getCenter(),
            draggable: true,
            cursor: 'move',
            raiseOnDrag: true
        });

        marker.setMap(map);
    }
    </script>
    <script>


    chooseLngLat({$info.longitude|default="118.087632"},{$info.latitude|default="24.442923"});

    function searchamap(){

        if($('#amapKeywords').val()=='' || $('#amapCity').val()==''){
            alert('请输入搜索关键字 跟 城市名称');
            return ;
        }
        $.ajax({
            type: "POST",
            // url: "http://restapi.amap.com/v3/assistant/inputtips?key=846cde7d790d0a51e901b1a36e83b53e&keywords="+amapKeywords+"&types=&location=&city="+amapCity+"&datatype=poi",
            url: "/Admin/Customer/amap",
            headers: {},
            data: {
                keywords: $('#amapKeywords').val(),
                city: $('#amapCity').val()
            },
            dataType: "json",// html/json/jsonp/xml
            success: function(msg){
                if(msg.info=='OK'){
                    chooseLngLat(msg.location.Lng,msg.location.Lat);
                }else{
                    alert('连接高德服务器失败。请直接前往高德网站获取坐标。')
                }
            },
            error: function(){
                
            }
        });
    }









        //    chooseLngLat(118.087632,24.442923);

    // function chooseLngLat(Lng, Lat) {
    //     var chooseLng = '';
    //     var chooseLat = '';

    //     map = new AMap.Map('container', {
    //         center: [Lng, Lat],
    //         zoom: 22
    //     });
    //     map.setDefaultCursor("url('http://aliyun06.hjie.net:8060/Tpl/Console/Public/Bizcard/icon/datouzhens.png'),pointer"); //替换大头针的样式

    //     //为地图注册click事件获取鼠标点击出的经纬度坐标
    //     var clickEventListener = map.on('click', function(e) {
    //         // document.getElementById("lnglat").value = e.lnglat.getLng() + ',' + e.lnglat.getLat();

    //         document.getElementById("latitude").value = e.lnglat.getLat();
    //         document.getElementById("longitude").value = e.lnglat.getLng();
    //         chooseLng = e.lnglat.getLng(); //用户点击时间获取的经纬度
    //         chooseLat = e.lnglat.getLat();
    //         //            alert(chooseLng);
    //         chooseLngLat(chooseLng, chooseLat);
    //         regeocoder(chooseLng, chooseLat, 1);
    //     });

    //     //用大头针在地图上将位置标注
    //     var marker = new AMap.Marker({
    //         position: map.getCenter(),
    //         draggable: true,
    //         cursor: 'move',
    //         raiseOnDrag: true
    //     });

    //     marker.setMap(map);
    // }
    </script>
</body>

</html>
